﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using BusinessObject;
using System.Data;
using Entity;

namespace GreenLife.Admin
{
    public partial class DanhSachLinkWeb : System.Web.UI.Page
    {
        LinkWebBO lwBO = new LinkWebBO();
        DataSet ds;
        protected void Page_Load(object sender, EventArgs e)
        {
            int page = int.Parse("0" + Request.QueryString["page"]);
            if (page == 0) page = 1;
            if (!IsPostBack)
            {
                NapDuLieu(page, 3, 5);
            }
        }
        public void NapDuLieu(int currPage, int recodperpage, int Pagesize)
        {
            DataSet ds = lwBO.phanTrangGreenLife(currPage, recodperpage, Pagesize);
            DataTable dtbData = ds.Tables[0];
            DataTable dtbPhanTrang = ds.Tables[1];
            if (dtbData.Rows.Count > 0)
            {
                listLinkWeb.DataSource = dtbData;
                listLinkWeb.DataBind();
                if (dtbPhanTrang.Rows.Count > 0)
                {
                    ltlPhanTrang.Text = dtbPhanTrang.Rows[0]["PhanTrang"] + "";
                }
            }
        }
        protected void cpRepeaterLinkWeb_ItemDataBound(object sender, RepeaterCommandEventArgs e)
        {
            if (e.CommandName == "delete")
            {
                int sno = Int32.Parse(e.CommandArgument.ToString());
                LinkWeb lw = new LinkWeb();
                lw.LinkWebID = sno;
                lwBO.removeLinkWeb(lw);
                int page = int.Parse("0" + Request.QueryString["page"]);
                if (page == 0) page = 1;
                NapDuLieu(page, 3, 5);
            }
        }
    }
}